package com.hxc.web.controller.apply;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hxc.common.annotation.Log;
import com.hxc.common.core.controller.BaseController;
import com.hxc.common.core.domain.AjaxResult;
import com.hxc.common.enums.BusinessType;
import com.hxc.apply.domain.TApplyInfo;
import com.hxc.apply.service.ITApplyInfoService;
import com.hxc.common.utils.poi.ExcelUtil;

/**
 * 在线办理应用信息Controller
 * 
 * @author hxc
 * @date 2021-08-16
 */
@Api(tags = "应用管理")
@RestController
@RequestMapping("/apply/info")
public class TApplyInfoController extends BaseController
{
    @Autowired
    private ITApplyInfoService tApplyInfoService;

    /**
     * 查询在线办理应用信息列表
     */
    @PreAuthorize("@ss.hasPermi('apply:info:list')")
    @GetMapping("/list")
    public AjaxResult list(TApplyInfo tApplyInfo)
    {
        List<TApplyInfo> list = tApplyInfoService.selectTApplyInfoList(tApplyInfo);
        return AjaxResult.success(list);
    }

    /**
     * 查询在线办理应用信息列表
     */
    @PreAuthorize("@ss.hasPermi('apply:info:list')")
    @GetMapping("/parentApplyList")
    public AjaxResult parentApplyList(TApplyInfo tApplyInfo)
    {
        tApplyInfo.setParentId(0L);
        List<TApplyInfo> list = tApplyInfoService.selectTApplyInfoList(tApplyInfo);
        return AjaxResult.success(list);
    }

    /**
     * 导出在线办理应用信息列表
     */
    @PreAuthorize("@ss.hasPermi('apply:info:export')")
    @Log(title = "在线办理应用信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TApplyInfo tApplyInfo)
    {
        List<TApplyInfo> list = tApplyInfoService.selectTApplyInfoList(tApplyInfo);
        ExcelUtil<TApplyInfo> util = new ExcelUtil<TApplyInfo>(TApplyInfo.class);
        return util.exportExcel(list, "在线办理应用信息数据");
    }

    /**
     * 获取在线办理应用信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('apply:info:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tApplyInfoService.selectTApplyInfoById(id));
    }

    /**
     * 新增在线办理应用信息
     */
    @PreAuthorize("@ss.hasPermi('apply:info:add')")
    @Log(title = "在线办理应用信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TApplyInfo tApplyInfo)
    {
        return toAjax(tApplyInfoService.insertTApplyInfo(tApplyInfo));
    }

    /**
     * 修改在线办理应用信息
     */
    @PreAuthorize("@ss.hasPermi('apply:info:edit')")
    @Log(title = "在线办理应用信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TApplyInfo tApplyInfo)
    {
        return toAjax(tApplyInfoService.updateTApplyInfo(tApplyInfo));
    }

    /**
     * 删除在线办理应用信息
     */
    @PreAuthorize("@ss.hasPermi('apply:info:remove')")
    @Log(title = "在线办理应用信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tApplyInfoService.deleteTApplyInfoByIds(ids));
    }

    /**
     * 应用信息列表
     */
    @ApiOperation(value = "应用信息列表(树形)")
    @GetMapping("/queryApplyList")
    public AjaxResult queryApplyList()
    {
        List<TApplyInfo> tApplyInfos = tApplyInfoService.queryApplyList();
        return AjaxResult.success(tApplyInfos);
    }

    /**
     * 应用信息列表
     */
    @ApiOperation(value = "查询应用列表(微信端)")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "applyId", value = "应用父类id(多个用,隔开)",dataType = "String")
    })
	@GetMapping("/queryApply")
    public AjaxResult queryApply(String applyId)
    {
        List<TApplyInfo> tApplyInfos = tApplyInfoService.queryApply(applyId);
        return AjaxResult.success(tApplyInfos);
    }

}
